// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="ResourceHelper.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the ResourceHelper type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace ScrumForTeamSystem.EventService.AggregationService
{
    using System.IO;
    using System.Reflection;

    using DataObjects;

    using Properties;

    /// <summary>
    /// Defines the ResourceHelper type.
    /// </summary>
    public static class ResourceHelper
    {
        /// <summary>
        /// Loads the rules from the specified path..
        /// </summary>
        /// <returns>
        /// The rules collection loaded from the specfied path.
        /// </returns>
        public static AggregateRulesCollection LoadRules()
        {
            var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    "ScrumForTeamSystem.EventService.AggregationService.AggregationRulesCollection.xsd");

            if (resourceStream == null)
            {
                throw new FileNotFoundException("Unable to load schema file resource.");
            }

            AggregateRulesCollection rules;
            Infrastructure.ResourceHelper.TryLoadRules(Settings.Default.RulesFilePath, resourceStream, out rules);
            return rules;
        }
   }
}